package xyz.yolin.test;

import java.util.*;

public class myCompare {
    public static void main(String[] args) {
        String a = "a";  //Ascll=97
        String b = "b";  //Ascll=98
        String c = "a";  //Ascll=97
        String d = "d";  //Ascll=100
        int i = a.compareTo(b);
        System.out.println(i);  // -1
        int j = a.compareTo(c);
        System.out.println(j);  // 0
        int k = b.compareTo(a);
        System.out.println(k);  //1
        System.out.println(d.compareTo(a));  //3


        System.out.println("----------------------");
        TreeSet<Student> treeset=new TreeSet<Student>();
        Student s1=new Student("张三",20);
        Student s2=new Student("李四",22);
        Student s3=new Student("王五",18);
        Student s4=new Student("王麻子",18);
        treeset.add(s1);
        treeset.add(s2);
        treeset.add(s3);
        treeset.add(s4);

        System.out.println(s1.compareTo(s2));
        System.out.println(s1.compareTo(s3));
        Iterator<Student> it = treeset.iterator();
        while (it.hasNext()){
            Student next = it.next();
            System.out.println(next.getName()+" "+next.getAge());
        }
    }
}